package com.neusoft;

import java.time.LocalDate;
import java.time.Period;

public class util {
    public static int calculateAge(LocalDate dateOfBirth, LocalDate currentDate) {
        if (dateOfBirth != null && currentDate != null) {
            return Period.between(dateOfBirth, currentDate).getYears();
        } else {
            throw new IllegalArgumentException("日期不能为空");
        }
    }
}
